
<template>
    <div class="wrap" style="padding: 15px">
      
      <el-button type="primary" @click="addCompetition" style="margin-bottom: 15px"
        >新增</el-button
      >
  

      <el-table :data="tableData" style="width: 100%" stripe v-loading="loading">
        <el-table-column label="规则名称" prop="name"></el-table-column>
        <el-table-column label="创建时间" prop="createTime"></el-table-column>
       
  
        <el-table-column label="操作" width="400">
          <template slot-scope="scope">
            <el-button type="primary" size="small" @click="edit(scope.row)"
              >编辑</el-button
            >
            <el-button type="danger" size="small" @click="del(scope.row.id)"
              >删除</el-button
            >
  
          </template>
        </el-table-column>
      </el-table>
      <div class="block" style="text-align: right">
        <el-pagination
          @size-change="getData"
          @current-change="getData"
          :current-page.sync="queryParams.page"
          :page-sizes="[10, 20, 30, 40]"
          :page-size.sync="queryParams.pageSize"
          layout="total, sizes, prev, pager, next, jumper"
          :total="total"
        ></el-pagination>
      </div>
      <List ref="list" /> 
    </div>
  </template>
  <script>
  import List from './list.vue'
  import { gameTemplatePageList, gameDel ,gameTemplateDel} from '@/config/api'
  export default {
    components: {
      List,
    },
    data () {
      return {
        queryParams: {
          name: undefined,
          position: undefined,
          page: 1,
          pageSize: 10,
        },
        tableData: [
  
        ],
        total: 0,
        loading: false,
  
  
      };
    },
  
    created () {
      this.getData()
    },
    methods: {
  
      // 新增赛事
      addCompetition(){
        this.$router.push("/sports/rule")
      },
      // 编辑
      edit (recore) {
        this.$router.push("/sports/rule?id="+recore.id)
      },
     
      getData () {
        gameTemplatePageList(this.queryParams).then(res => {
          this.tableData = res.data.result.list
          this.total = res.data.result.total
        })
      },
      del (id) {
        this.$confirm('此操作将删除该规则, 是否继续?', '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        }).then(() => {
            gameTemplateDel({ id }).then(res => {
            if (res.data.status == 200) {
              this.getData()
              this.$message({
                type: 'success',
                message: '删除成功!'
              });
            }
  
          })
  
        }).catch(() => {
          this.$message({
            type: 'info',
            message: '已取消删除'
          });
        });
      },
    },
  };
  </script>
  